<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListUfTitle}"></h:outputText>
        </ui:define>

        <ui:define name="body">
            
            <h:form id="formTableUf" prependId="false" >
                
                <p:dataTable id="dataTableUf" var="selected" value="#{ufController.listarUf}">
                    
                    <f:facet name="header">#{bundle.ListUfTitle}</f:facet>
                    <p:column id="descricao" sortBy="#{ufController.selected.descricao}">
                        <f:facet name="header">#{bundle.ListUfTitle_descricao}</f:facet>
                        <h:outputText value="#{selected.descricao}" />
                    </p:column>
                    
                    <p:column id="sigla">
                        <f:facet name="header">#{bundle.ListUfTitle_sigla}</f:facet>
                        <h:outputText value="#{selected.sigla}" />
                    </p:column>
                    
                    <p:column id="acoes" colspan="2">
                        <f:facet name="header">
                            <p:commandButton icon="ui-icon-plusthick" value="#{bundle.CreateUfTitle}" actionListener="#{ufController.prepareCreate}" update=":formDialogCreate:createUf" oncomplete="dialogCreate.show()"/>
                        </f:facet>
                        <p:commandButton value="#{bundle.ViewUfEditLink}" actionListener="#{ufController.prepareEdit}" update=":formDialogEdit:editUf" oncomplete="dialogEdit.show()"/>
                        <p:commandButton value="#{bundle.ViewAroDestroyLink}" actionListener="#{ufController.destroy}" update=":formTableUf:dataTableUf"/>
                    </p:column>
                    
                </p:dataTable>
                
            </h:form>

            <p:dialog header="#{bundle.EditUfTitle}" widgetVar="dialogEdit" resizable="true" modal="true" showEffect="slide" width="500">
                <h:form id="formDialogEdit" prependId="false">

<!--                    <h:panelGrid id="editUf" columns="2">-->
                        
                        <p:panelGrid id="editUf" columns="2">
                            
                            <p:outputLabel for="editUfDescricao" value="#{bundle.EditUfLabel_descricao}" />                        
                            <p:inputText id="editUfDescricao" value="#{ufController.selected.descricao}"/>

                            <p:outputLabel for="editUfSigla" value="#{bundle.EditUfLabel_sigla}" />
                            <p:inputText id="editUfSigla" value="#{ufController.selected.sigla}"/>

                            <p:commandButton oncomplete="dialogEdit.hide();" actionListener="#{ufController.update}" update=":formTableUf:dataTableUf" value="#{bundle.EditUfSaveLink}"/>
                            <p:commandButton oncomplete="dialogEdit.hide();" value="Cancelar"/>
                        </p:panelGrid>
                        
<!--                    </h:panelGrid>-->
                </h:form>
            </p:dialog>

            <p:dialog header="#{bundle.CreateUfTitle}" widgetVar="dialogCreate" resizable="true" modal="true" showEffect="slide" width="500">
                <h:form id="formDialogCreate" prependId="false">

                    <h:panelGrid id="createUf" columns="2">

                        <h:outputLabel for="#{bundle.CreateUfTitle_descricaoID}" value="#{bundle.CreateUfLabel_descricao}" />
                        <h:inputText id="#{bundle.CreateUfTitle_descricaoID}" value="#{ufController.selected.descricao}"/>

                        <h:outputLabel for="#{bundle.CreateUfTitle_siglaID}" value="#{bundle.CreateUfLabel_sigla}" />
                        <h:inputText id="#{bundle.CreateUfTitle_siglaID}" value="#{ufController.selected.sigla}"/>

                        <p:commandButton value="#{bundle.CreateUfSaveLink}" actionListener="#{ufController.create}" update=":formTableUf:dataTableUf" oncomplete="dialogCreate.hide();"/>
                        <p:commandButton oncomplete="dialogCreate.hide();" value="Cancelar"/>

                    </h:panelGrid>
                </h:form>
            </p:dialog>
        </ui:define>
    </ui:composition>

</html>